Skip to content

Add config store read path and split storage module (PR3)#548

Merged
prk-Jr merged 28 commits intomainfrom
feature/edgezero-pr3-config-store
Apr 1, 2026
Merged

Add config store read path and split storage module (PR3)#548
prk-Jr merged 28 commits intomainfrom
feature/edgezero-pr3-config-store

Conversation

@prk-Jr
Copy link
Copy Markdown
Collaborator

@prk-Jr prk-Jr commented Mar 23, 2026

Summary

  • Split fastly_storage.rs into storage/{config_store,secret_store,api_client,mod}.rs for better separation of concerns
  • Add PlatformConfigStore read path in the Fastly adapter (FastlyPlatformConfigStore::get via ConfigStore::try_open/try_get)
  • Migrate get_active_jwks and handle_trusted_server_discovery to use &RuntimeServices instead of the legacy FastlyConfigStore directly

Changes

File Change
crates/trusted-server-core/src/storage/mod.rs New module root; re-exports StoreName, StoreId, UnavailableKvStore
crates/trusted-server-core/src/storage/config_store.rs New: PlatformConfigStore stub with read support and NotImplemented write stubs
crates/trusted-server-core/src/storage/secret_store.rs New: PlatformSecretStore with NotImplemented write stubs
crates/trusted-server-core/src/storage/api_client.rs Renamed/trimmed from fastly_storage.rs; retains API client helpers
crates/trusted-server-core/src/fastly_storage.rs Deleted; replaced by storage/ module
crates/trusted-server-core/src/lib.rs Export storage module; remove fastly_storage export
crates/trusted-server-core/src/platform/error.rs Add PlatformError::NotImplemented variant
crates/trusted-server-core/src/platform/traits.rs Document NotImplemented on write methods in trait doc comments
crates/trusted-server-core/src/platform/types.rs Add StoreName/StoreId newtypes; add UnavailableKvStore; add RuntimeServicesBuilder
crates/trusted-server-adapter-fastly/src/platform.rs Add FastlyPlatformConfigStore::get; stub write methods on config/secret store impls
crates/trusted-server-adapter-fastly/src/main.rs Use RuntimeServicesBuilder; update import paths after storage module rename
crates/trusted-server-core/src/request_signing/jwks.rs Migrate get_active_jwks to accept &RuntimeServices
crates/trusted-server-core/src/request_signing/endpoints.rs Migrate handle_trusted_server_discovery to accept &RuntimeServices; add success-path test using StubJwksConfigStore
crates/trusted-server-core/src/request_signing/rotation.rs Update call site (mechanical import rename)
crates/trusted-server-core/src/request_signing/signing.rs Update call site (mechanical import rename)

Closes

Closes #484

Test plan

  • cargo test --workspace
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check
  • JS tests: cd crates/js/lib && npx vitest run
  • JS format: cd crates/js/lib && npm run format
  • Docs format: cd docs && npm run format
  • WASM build: cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1

Checklist

  • Changes follow CLAUDE.md conventions
  • No unwrap() in production code — use expect("should ...")
  • Uses tracing macros (not println!)
  • New code has tests
  • No secrets or credentials committed

prk-Jr and others added 13 commits March 18, 2026 16:54
Rename crates/common → crates/trusted-server-core and crates/fastly →
crates/trusted-server-adapter-fastly following the EdgeZero naming
convention. Add EdgeZero workspace dependencies pinned to rev 170b74b.
Update all references across docs, CI workflows, scripts, agent files,
and configuration.
Introduces trusted-server-core::platform with PlatformConfigStore,
PlatformSecretStore, PlatformKvStore, PlatformBackend, PlatformHttpClient,
and PlatformGeo traits alongside ClientInfo, PlatformError, and
RuntimeServices. Wires the Fastly adapter implementations and threads
RuntimeServices into route_request. Moves GeoInfo to platform/types as
platform-neutral data and adds geo_from_fastly for field mapping.
- Defer KV store opening: replace early error return with a local
  UnavailableKvStore fallback so routes that do not need synthetic ID
  access succeed when the KV store is missing or temporarily unavailable
- Use ConfigStore::try_open + try_get and SecretStore::try_get throughout
  FastlyPlatformConfigStore and FastlyPlatformSecretStore to honour the
  Result contract instead of panicking on open/lookup failure
- Encapsulate RuntimeServices service fields as pub(crate) with public
  getter methods (config_store, secret_store, backend, http_client, geo)
  and a pub new() constructor; adapter updated to use new()
- Reference #487 in FastlyPlatformHttpClient stub (PR 6 implements it)
- Remove unused KvPage re-export from platform/mod.rs
- Use super::KvHandle shorthand in RuntimeServices::kv_handle()
- Split fastly_storage.rs into storage/{config_store,secret_store,api_client,mod}.rs
- Add PlatformConfigStore read path via FastlyPlatformConfigStore::get using ConfigStore::try_open/try_get
- Add PlatformError::NotImplemented variant; stub write methods on FastlyPlatformConfigStore and FastlyPlatformSecretStore
- Add StoreName/StoreId newtypes with From<String>, From<&str>, AsRef<str>
- Add UnavailableKvStore to core platform module
- Add RuntimeServicesBuilder replacing 7-arg constructor
- Migrate get_active_jwks and handle_trusted_server_discovery to use &RuntimeServices
- Update call sites in signing.rs, rotation.rs, main.rs
- Add success-path test for handle_trusted_server_discovery using StubJwksConfigStore
- Fix test_parse_cookies_to_jar_empty typo (was emtpy)
@prk-Jr prk-Jr self-assigned this Mar 23, 2026
Copy link
Copy Markdown
Collaborator

@ChristianPavilonis ChristianPavilonis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Well-structured PR — the storage module split is clean, the PlatformConfigStore read path is correctly implemented, and the migration to &RuntimeServices preserves error context properly. No blockers. CI is fully green.

Highlights:

  • Strong newtype pattern for StoreName/StoreId prevents mix-up bugs
  • RuntimeServicesBuilder with exhaustive expect("should ...") messages
  • Graceful KV store degradation with UnavailableKvStore fallback
  • Excellent test_handle_trusted_server_discovery_returns_jwks_document test

Findings: 0 blockers, 2 high, 4 medium, 3 low


Findings placed in body (line not in diff)

🤔 [P2] Value not URL-encoded (pre-existing)crates/trusted-server-core/src/storage/api_client.rs line 122

The payload format!("item_value={}", value) sends application/x-www-form-urlencoded content but doesn't actually URL-encode value. If value contains &, =, +, spaces, or JSON characters ({, }, "), the Fastly API may misinterpret it. This is pre-existing code (moved from fastly_storage.rs) but worth flagging since it's used in key rotation.

Consider: let payload = format!("item_value={}", urlencoding::encode(value));

Copy link
Copy Markdown
Collaborator

@aram356 aram356 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good. Ship it

prk-Jr and others added 3 commits March 25, 2026 10:29
- Make StoreName and StoreId inner fields private; From/AsRef provide all
  needed construction and access
- Add #[deprecated] to GeoInfo::from_request with #[allow(deprecated)] at
  the three legacy call sites to track migration progress
- Enumerate the six platform traits in the platform module doc comment
- Extract backend_config_from_spec helper to remove duplicate BackendConfig
  construction in predict_name and ensure
- Replace .into_iter().collect() with .to_vec() on secret plaintext bytes
- Remove unused bytes dependency from trusted-server-adapter-fastly
- Add comment on SecretStore::open clarifying it already returns Result
  (unlike ConfigStore::open which panics)
@prk-Jr prk-Jr changed the base branch from main to feature/edgezero-pr2-platform-traits March 30, 2026 09:43
@prk-Jr prk-Jr changed the title Add config store read path and split storage module Add config store read path and split storage module (PR3) Mar 31, 2026
Copy link
Copy Markdown
Collaborator

@aram356 aram356 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good

@prk-Jr prk-Jr changed the base branch from feature/edgezero-pr2-platform-traits to main April 1, 2026 06:15
@prk-Jr prk-Jr merged commit 07aa943 into main Apr 1, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Split fastly_storage.rs + config store trait (read-only)

4 participants